<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>计数器</title>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<div id="app">
    <button type="warning" @click="sub">-</button>
    <span>{{num}}</span>
    <button type="warning" @click="add">+</button>
    <el-button round>圆角按钮</el-button>
</div>
<script>
    var app = new Vue({
        el:"#app",
        data:{
             num:1
        },
        methods:{
           add:function () {
               // console.log('add')
               if(this.num<10){
               this.num++;}
               else {
                   alert("抱歉，已经是最大值了哦")
               }
           },
           sub:function () {
               // console.log('sub')
               if(this.num>0){
               this.num--;}
               else {
                   alert("不能为负值哦")
               }
           }
        },
    })
</script>
</body>
</html>
